<template>
  <div>
    <el-card>
      <el-table :data="alarmData" style="width: 100%">
        <el-table-column prop="area" label="服务区" width="180"></el-table-column>
        <el-table-column prop="index" label="指标"></el-table-column>
        <el-table-column prop="level" label="报警等级"></el-table-column>
        <el-table-column prop="time" label="时间"></el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
  data: function() {
    return {
      // 为什么在这里面定义的所有数据都是undefined呢
      alarmData: []
    };
  },
  methods: {
    getIndexAlarm: function() {
      this.$axios
        .get("/indexAlarm")
        .then(response => {
          this.alarmData = JSON.parse(response.data)["indexAlarms"];
        })
        .catch(error => {
          console.log(error);
        });
    }
  },
  mounted: function() {
    this.getIndexAlarm();
  }
};
</script>